package com.pt.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.pt.manage.domain.vo.voNotification;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pt.common.annotation.Log;
import com.pt.common.core.controller.BaseController;
import com.pt.common.core.domain.AjaxResult;
import com.pt.common.enums.BusinessType;
import com.pt.manage.domain.Notification;
import com.pt.manage.service.INotificationService;
import com.pt.common.utils.poi.ExcelUtil;
import com.pt.common.core.page.TableDataInfo;

/**
 * 通知Controller
 * 
 * @author wxt
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/manage/notification")
public class NotificationController extends BaseController
{
    @Autowired
    private INotificationService notificationService;

    /**
     * 查询通知列表
     */
    @PreAuthorize("@ss.hasPermi('manage:notification:list')")
    @GetMapping("/list")
    public TableDataInfo list(Notification notification)
    {
        startPage();
        List<voNotification> list = notificationService.selectNotificationList(notification);
        return getDataTable(list);
    }

    /**
     * 查询通知列表
     */

    @GetMapping("/listStudent")
    public TableDataInfo listStudent(Notification notification)
    {
        startPage();
        List<voNotification> list = notificationService.selectsNotificationList(notification);
        return getDataTable(list);
    }
    /**
     * 导出通知列表
     *-
    @PreAuthorize("@ss.hasPermi('manage:notification:export')")
    @Log(title = "通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Notification notification)
    {
        List<voNotification> list = notificationService.selectNotificationList(notification);
        ExcelUtil<voNotification> util = new ExcelUtil<voNotification>(voNotification.class);
        util.exportExcel(response, list, "通知数据");
    }

    /**
     * 获取通知详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:notification:query')")
    @GetMapping(value = "/{NotificationID}")
    public AjaxResult getInfo(@PathVariable("NotificationID") Long NotificationID)
    {
        return success(notificationService.selectNotificationByNotificationID(NotificationID));
    }

    /**
     * 新增通知
     */
    @PreAuthorize("@ss.hasPermi('manage:notification:add')")
    @Log(title = "通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Notification notification)
    {
        return toAjax(notificationService.insertNotification(notification));
    }

    /**
     * 修改通知
     */
    @PreAuthorize("@ss.hasPermi('manage:notification:edit')")
    @Log(title = "通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Notification notification)
    {
        return toAjax(notificationService.updateNotification(notification));
    }

    /**
     * 删除通知
     */
    @PreAuthorize("@ss.hasPermi('manage:notification:remove')")
    @Log(title = "通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{NotificationIDs}")
    public AjaxResult remove(@PathVariable Long[] NotificationIDs)
    {
        return toAjax(notificationService.deleteNotificationByNotificationIDs(NotificationIDs));
    }
}
